﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FireStarter.CodeGeneration.Generator;
using NUnit.Framework;

namespace FireStarter.Test.CodeGeneration.Generator
{
    [TestFixture]
    public class TestIncludeExpression : TestBase
    {
        [Test]
        public void Test_Creation()
        {
            //---------------Set up test pack-------------------
            //<<|INCLUDE(part)|>>
            // where the "part" include resolves in parsing to "part"
            LiteralExpression partExpression = new LiteralExpression("part");
            LiteralExpression nextExpression = null;
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            IncludeExpression includeExpression = new IncludeExpression(partExpression, nextExpression);
            //---------------Test Result -----------------------
            Assert.AreSame(partExpression, includeExpression.Part);
            Assert.IsNull(includeExpression.Next);
        }

        [Test]
        public void Test_CreationWithNext()
        {
            //---------------Set up test pack-------------------
            //<<|INCLUDE(part)|>>bob
            // where the "part" include resolves in parsing to "part"
            LiteralExpression partExpression = new LiteralExpression("part");
            LiteralExpression nextExpression = new LiteralExpression("bob");
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            IncludeExpression includeExpression = new IncludeExpression(partExpression, nextExpression);
            //---------------Test Result -----------------------
            Assert.AreSame(partExpression, includeExpression.Part);
            Assert.AreSame(nextExpression, includeExpression.Next);
        }

        [Test]
        public void Test_Generate()
        {
            //---------------Set up test pack-------------------
            //<<|INCLUDE(part)|>>
            // where the "part" include resolves in parsing to "part"
            string literal = "part";
            LiteralExpression partExpression = new LiteralExpression(literal);
            LiteralExpression nextExpression = null;
            IncludeExpression includeExpression = new IncludeExpression(partExpression, nextExpression);
            var modelStrategyMapper = new ModelStrategyMapper();
            //---------------Execute Test ----------------------
            string result = includeExpression.Generate(modelStrategyMapper, new ModelElementStub());
            //---------------Test Result -----------------------
            StringAssert.AreEqualIgnoringCase(literal, result);
        }
    }
}
